import { RuleForm } from "@renderer/interface/login";
import { Encrypt } from "@renderer/utils/aes";
import { Ref } from "vue";

export const useMemoPassword = (isRemember: Ref<boolean>, form: RuleForm) => {
	function onRemember() {
		localStorage.setItem('isRemember', JSON.stringify(isRemember.value))
		localStorage.setItem('username', form.username)
		if (isRemember.value) {
			localStorage.setItem('password', Encrypt(form.password))
		} else {
			localStorage.removeItem('password')
		}
	}
	return { onRemember }
}